package com.wondersgroup.fjzlpt.plat.dao.impl;

import com.alibaba.fastjson.JSONObject;
import com.quick.framework.boot.repository.sql.bean.SQLBean;
import com.quick.framework.boot.repository.sql.jdbcTemplate.impl.BaseJTDAOImpl;
import com.quick.framework.boot.repository.sql.jdbcTemplate.impl.SqlBeanBaseJTDaoImpl;
import com.wondersgroup.fjzlpt.plat.dao.inter.AuthUserDAO;
import org.springframework.stereotype.Repository;

/**
 * Created by lion on 2017/8/25.
 */
@Repository
public class AuthUserDaoImpl extends SqlBeanBaseJTDaoImpl implements AuthUserDAO {
    /**
     * 查询用户密码
     * @param userId
     * @return
     */
    public String queryUserPwd(String userId){
        StringBuilder sbud = new StringBuilder("select PASSWORD from TB_AUTH_USER where 1=1 and USERID=?");
        SQLBean sb = new SQLBean(sbud.toString(), new Object[]{userId});
        JSONObject json = this.queryOne(sb);
        return json.getString("PASSWORD");
    }

    /**
     * 更新用户密码
     * @param userId
     * @param password
     */
    public void updateUserPwd(String userId, String password){
        StringBuilder sbud = new StringBuilder("update TB_AUTH_USER set PASSWORD=? WHERE USERID=?");
        SQLBean sb = new SQLBean(sbud.toString(), new Object[]{password, userId});
        this.execute(sb);
    }
}
